import { createSlice } from "@reduxjs/toolkit";
import dayjs from "dayjs";

export const CitySlice = createSlice({
  name: "CitySlice",
  initialState: {
    start:"北京",
    end:"广州",
    date:dayjs().format("YYYY-MM-DD")

  },
  reducers: {
    EditCityClick(state, { payload }) {
      state[payload.type] = payload.city;
    },

    EditTime(state,{payload}){
      state.date=payload.date
    },

    CExchangeCity(state){
      const tt=state.start
      state.start=state.end
      state.end=tt
    }
  },
});

// Action creators are generated for each case reducer function
export const { EditCityClick ,EditTime,CExchangeCity} = CitySlice.actions;

export default CitySlice.reducer;
